package com.tengju.data.infrastructure.repository.clickhouse.wechat;

import com.tengju.data.domain.model.clickhouse.wechat.WechatUserInfo;
import com.tengju.data.domain.model.clickhouse.wechat.WechatUserInfoRepository;
import com.tengju.data.infrastructure.persistence.mybatis.dataobject.WechatUserInfoDO;
import com.tengju.data.infrastructure.persistence.mybatis.mapper.clickhouse.wechat.WechatUserInfoDOMapper;
import com.tengju.data.infrastructure.repository.clickhouse.convert.WechatUserInfoConvert;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author: 李大仙
 * @date: 2021/12/15 2:58 下午
 */
@Repository
@RequiredArgsConstructor(onConstructor_ = {@Autowired})
public class WechatUserInfoRepositoryImpl implements WechatUserInfoRepository {

    private final WechatUserInfoDOMapper wechatUserInfoDOMapper;

    @Override
    public List<WechatUserInfo> getAll() {
        List<WechatUserInfoDO> wechatUserInfoDOList = wechatUserInfoDOMapper.selectAll();
        return wechatUserInfoDOList.stream()
                .map(WechatUserInfoConvert::convert)
                .collect(Collectors.toList());
    }
}
